package com.lzw.mapper.admin;
import com.lzw.pojo.Dormitory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DormitoryManagementMapper {

    //查询公寓
    List<Dormitory> listDormitory(@Param("dormitoryId") Integer dormitoryId, @Param("buildingId") Integer buildingId);

    //添加公寓
    @Insert("INSERT INTO dormitorymanagement.dormitory(dormitory_id, building_id) VALUES (#{dormitoryId}, #{buildingId})")
    void addDormitory(Dormitory dormitory);

    //删除公寓
    void deleteDormitory(@Param("ids") List<Integer> ids);

    //根据id查询公寓
    @Select("SELECT * FROM dormitorymanagement.dormitory WHERE dormitory_id = #{dormitoryId}")
    Dormitory getDormitoryById(int id);

    @Select("SELECT COUNT(*) FROM dormitorymanagement.dormitory WHERE dormitory_id = #{dormitoryId}")
    int countById(Integer dormitoryId);

    //根据楼宇ID删除宿舍
    void deleteDormitoryByBuildingId(@Param("ids") List<Integer> ids);
}
